package day08.tesk;

import java.util.Scanner;

public abstract class Express {
    private int weight;
    private int money;
    public int getMoney() {
        return money;
    }
    public void setMoney(int money) {
        this.money = money;
    }
    public Express(int weight) {
        this.weight = weight;
    }
    public int getWeight() {
        return weight;
    }
    public abstract void getTotal();
}
class SLExpress extends Express {
private int age;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public SLExpress(int weight) {
        super(weight);
    }

    @Override
    public void getTotal() {
        if (getWeight() <= 1) {
            setMoney(12);
        } else {
            super.setMoney(12 + (getWeight() - 1) * 2);

        }
        System.out.println("SLExpress:" + getMoney());
    }
}

class DDExpress extends Express {
    public DDExpress(int weight) {
        super(weight);
    }

    @Override
    public void getTotal() {
        if (getWeight() <= 1) {
            setMoney(5);
        } else {
            super.setMoney(4 + getWeight());
        }
        System.out.println("DDExpress:" + getMoney());
    }
}

class Main3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Express[] e1 = new Express[n];
        for (int i = 0; i < n; i++) {
            String type = sc.next();
            if (type.equals("SL")) {
                e1[i] = new SLExpress(sc.nextInt());
            } else {
                e1[i] = new DDExpress(sc.nextInt());
            }
        }
        for (Express e2 : e1) {
            e2.getTotal();
        }
    }
}
